package tutorial;

import java.util.List;

import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.WorldRenderer;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.item.EnumToolMaterial;
import net.minecraft.item.Item;
import net.minecraft.item.ItemAxe;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.CraftingManager;
import net.minecraft.item.crafting.FurnaceRecipes;
import net.minecraft.item.crafting.IRecipe;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.modloader.BaseModTicker;
import cpw.mods.fml.common.network.NetworkMod;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.common.registry.LanguageRegistry;
import cpw.mods.fml.common.registry.TickRegistry;
import cpw.mods.fml.relauncher.Side;

@Mod(modid = Tutorial.modid, name = "Tutorial Mod", version = "1.0")
@NetworkMod(clientSideRequired = true, serverSideRequired = false)
public class Tutorial 
{
	public static final String modid = "YourName_ModName";
	
	public static BlockTutorialBlock tutorialBlock;
	public static BridgeBlock bridgeBlock;
	
	public static Item tutorialItem;
	
	EventManager eventmanager = new EventManager();
	
	//@EventHandler
	public void load(FMLInitializationEvent event)
	{
		
		tutorialBlock = new BlockTutorialBlock(500, Material.rock);
		tutorialBlock.setUnlocalizedName("tutorialBlock");
		
		bridgeBlock = new BridgeBlock(501, Material.rock);
		bridgeBlock.setUnlocalizedName("bridgeBlock");
		
		GameRegistry.registerBlock(tutorialBlock, ItemTutorialBlock.class, modid + (tutorialBlock.getUnlocalizedName().substring(5)));
		GameRegistry.registerBlock(bridgeBlock, ItemTutorialBlock.class, modid + (bridgeBlock.getUnlocalizedName().substring(5)));

		List recipes = CraftingManager.getInstance().getRecipeList();
		
		try
		{
		int size = recipes.size();
        for (int j = 0; j < size; j++)
        {
            IRecipe irecipe = (IRecipe)recipes.get(j);
            if (irecipe == null)
            	continue;
            
            ItemStack result = irecipe.getRecipeOutput();
            
            if (result == null)
            	continue;
            
            if (result.itemID == Block.ladder.blockID)
            {	// found our match!
            	recipes.remove(j);
            	break;
            }
        }
		}
		catch (Exception ex)
		{
			recipes = null;
		}

		
        LanguageRegistry.addName(new ItemStack(bridgeBlock, 1, 0), "Bridge Block");
        LanguageRegistry.addName(new ItemStack(tutorialBlock, 1, 0), "Tutorial Block");
        LanguageRegistry.addName(new ItemStack(tutorialBlock, 1, 1), "Nether Tutorial Block");
		
		tutorialItem = new ItemTutorial(5000).setUnlocalizedName("tutorialItem");
		LanguageRegistry.addName(tutorialItem, "Tutorial Item");
		
		GameRegistry.registerWorldGenerator(eventmanager);
	
		
		TutorialCrafting.loadRecipes();
		Object O = Item.axeStone;
		
        this.gameTickHandler = new TutorialTickHandler();
        TickRegistry.registerTickHandler(this.gameTickHandler, Side.CLIENT);
	
	}
	
    private TutorialTickHandler gameTickHandler;

    public static Item axeFlint = (new ItemAxe(5215, EnumToolMaterial.WOOD)).setUnlocalizedName("hatchetFlint").setTextureName("wood_axe");
    //FLINT(0, 10, 2.0F, 0.0F, 15); <== supposed to add this into EnumToolMaterial!!!
    
}